package cn.iocoder.yudao.module.service.dal.mysql.message;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.service.controller.admin.message.vo.ServiceMessagePageReqVO;
import cn.iocoder.yudao.module.service.dal.dataobject.message.ServiceMessageDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 对话消息 Mapper
 *
 * @author 数创万维
 */
@Mapper
public interface ServiceMessageMapper extends BaseMapperX<ServiceMessageDO> {

    default PageResult<ServiceMessageDO> selectPage(ServiceMessagePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ServiceMessageDO>()
                .eqIfPresent(ServiceMessageDO::getUserType, reqVO.getUserType())
                .eqIfPresent(ServiceMessageDO::getMsgType, reqVO.getMsgType())
                .likeIfPresent(ServiceMessageDO::getMsgContent, reqVO.getMsgContent())
                .eqIfPresent(ServiceMessageDO::getFromUserId, reqVO.getFromUserId())
                .eqIfPresent(ServiceMessageDO::getToUserId, reqVO.getToUserId())
                .betweenIfPresent(ServiceMessageDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ServiceMessageDO::getId));
    }

}